package reflect;

import java.io.File;
import java.net.URISyntaxException;

public class Test {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, URISyntaxException {
        File dir = new File(
                Test.class.getResource(".").toURI()
        );
        System.out.println(dir);
        String packName = Test.class.getPackage().getName();
        System.out.println(packName);
        File[] subs = dir.listFiles(f -> f.getName().endsWith(".class"));
        for (File sub : subs) {
            String fileName = sub.getName();
            String className = fileName.substring(0, fileName.indexOf("."));
            Class cls = Class.forName(packName + "." + className);
            Object o = cls.newInstance();
            System.out.println(o);
        }
    }
}
//Person.class
//ReflectDemo1.class
//ReflectDemo2.class
//ReflectDemo3.class
//Student.class
//Test.class
